/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2021-12-15 09:37:47
 * @LastEditTime: 2022-01-26 10:56:10
 */
import ruleOpt from '@/biz/option/rule.js'
import Opt from '@/components/dt/info/Opt.js'
import organizationOpt from '@/biz/option/organization.js'
let _this = null

class SearchOpt extends Opt {

  constructor(vm) {
    _this = vm
    super()
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }


  createAll() {
    let cityAttrSort = [];
    this.all = [

      {
        title: '日期',
        placeholder: '请选择日期',
        xl: 7,
        key: 'time',
        date: {
          type: 'daterange'
        },
        data: {
          to: (v) => {
            return {
              startDate: v[0],
              endDate: v[1],
            }
          }
        }
      },
      {
        key: 'city',
        title: '所属城市',
        load: (o) => {
          organizationOpt.getAreacodePropertyList().then(res => {
            o.cascader.options = res
            cityAttrSort = res
          })
        },
        cascader: {
          options: cityAttrSort,

          loadData(item, callback) {
            console.log(item, 'aaaaaaaaaaa');
            item.loading = true;
            let params = {
              level: 3,
              page: "1",
              parentCode: item.value,
              rows: "100",
            };
            organizationOpt.getAreacodePropertyList2(params).then((res) => {
              res.list.map((itemL) => {
                itemL.value = itemL.cityCode;
                itemL.label = itemL.cityName;
                item.children.push(itemL);
              });

              item.loading = false;
              callback();
            });
          }
        }
      },
      {
        title: '案场名字',
        placeholder: '请输入案场名字',
        key: 'buildingName',
        input: {}
      },


    ]
  }
}

export default SearchOpt